package models

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	Name   string  `gorm:"type:varchar(255);not null"`
	Price  float64 `gorm:"type:decimal(10,2);not null"`
	Stock  int     `gorm:"type:int(11);not null"`
	Img    string  `gorm:"type:varchar(255);not null"`
	Status int     `gorm:"type:int(11);not null"`
}

func (g *Goods) GoodsAdd(db *gorm.DB) error {
	return db.Create(&g).Error
}

func (g *Goods) FindGoodsByID(db *gorm.DB, id int64) error {
	return db.Where("id = ?", id).First(&g).Error
}
